home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
3_0
/
DOUBLEDE
/
MENUS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-07-27
|
5KB
|
197 lines
#include "shell.h"
/*====================================================================
fixmenus()
adjust the menus to reflect the status of windows, ie, if our
application window is frontmost, enable printing menu items,
disable Undo,Cut,Paste,Clear, and enable Copy if the front
window is not the clipboard window.
if front window is _not_ our window, disable print items, and
enable _all_ of the edit menu items (in case the front window
is a Desk Accessory)
====================================================================*/
fixmenus()
{
if ((w_index = ourwindow(FrontWindow())) >= 0){
EnableItem(FileMenu,PageSetupItem);
EnableItem(FileMenu,PrintItem);
DisableItem(EditMenu,UndoItem);
DisableItem(EditMenu,CutItem);
DisableItem(EditMenu,PasteItem);
DisableItem(EditMenu,ClearItem);
if (FrontWindow() == clip_window)
DisableItem(EditMenu,CopyItem);
else
EnableItem(EditMenu,CopyItem);
}
else{
DisableItem(FileMenu,PageSetupItem);
DisableItem(FileMenu,PrintItem);
EnableItem(EditMenu,UndoItem);
EnableItem(EditMenu,CutItem);
EnableItem(EditMenu,PasteItem);
EnableItem(EditMenu,ClearItem);
EnableItem(EditMenu,CopyItem);
}
}
/*====================================================================
makemenus()
initialize and install the Apple, File, and Edit menus from the
resource fork of the application. Install Desk Accessories
(DRVRs) into the Apple menu
====================================================================*/
makemenus()
{
AddResMenu(AppleMenu= GetMenu(AppleID),(ResType)'DRVR');
SetItem(AppleMenu,1,"\pAbout LightspeedC Shell");
InsertMenu(AppleMenu,0);
InsertMenu(FileMenu= GetMenu(FileID),0);
InsertMenu(EditMenu= GetMenu(EditID),0);
DrawMenuBar();
}
/*====================================================================
doapplemenu(int)
do About... stuff if the menu item is 1, otherwise open a desk
accessory selected from the Apple Menu
====================================================================*/
doapplemenu(menuitem)
int menuitem;
{
Str255 accName;
switch(menuitem){
case AboutItem: doabout("LightspeedC Shell","07.27.88");
break;
default: GetItem(AppleMenu,menuitem,accName);
OpenDeskAcc(accName);
break;
}
}
/*====================================================================
dofilemenu(int)
dispatch to routines selected from the File menu. An alert
indicating a routine is not implemented is included for the
items that are not yet implemented.
====================================================================*/
dofilemenu(menuitem)
int menuitem;
{
switch(menuitem){
case NewItem: noimplementation();
break;
case OpenItem: noimplementation();
break;
case CloseItem: noimplementation();
break;
case SaveItem: noimplementation();
break;
case SaveAsItem: noimplementation();
break;
case PageSetupItem: dopagesetup();
break;
case PrintItem: print_it();
break;
case QuitItem: quitting = TRUE;
break;
default: break;
}
}
/*====================================================================
doeditmenu(int)
if the Show/Hide clipboard item is selected, branch to routine
that toggles is visibility.
otherwise, if the Edit menu item is not intended for a
Desk Accessory, (SystemEdit(item-1) == FALSE), then it
is ours to handle. After using an Edit menu item, branch
to "changedscrap()" to update the clipboard contents
====================================================================*/
doeditmenu(menuitem)
int menuitem;
{
if (menuitem==ClipItem)
showclipwindow();
else
if (!SystemEdit(menuitem-1)){
switch(menuitem){
case UndoItem: break;
case CutItem: break;
case CopyItem: break;
case PasteItem: break;
case ClearItem: break;
default: break;
}
changedscrap();
}
else{
changedscrap();
}
}
/*====================================================================
domenu(long)
the long contains the Menu ID in the HiWord, and the Menu Item
in the LoWord. Extract these, and dispatch to the individual
menu handling routines, passing to them the menu item selected
from their menu
====================================================================*/
domenu(mChoice)
long mChoice;
{
int MenuID,MenuItem;
MenuID = HiWord(mChoice);
MenuItem = LoWord(mChoice);
switch (MenuID){
case AppleID: doapplemenu(MenuItem);
break;
case FileID: dofilemenu(MenuItem);
break;
case EditID: doeditmenu(MenuItem);
break;
default: break;
}
HiliteMenu(0);
}